package com.xiaoai.io.bio1one;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

/**
 *
 * 服务端
 * @Author
 * @Date 2021-09-06 00:25
 */
public class Server {

    public static void main(String[] args){
        System.out.println("=====服务端1启动=====");
        ServerSocket ss;
        {
            try {
                ss = new ServerSocket(9999);
                // 监听客户端
                Socket socket = ss.accept();

                InputStream is = socket.getInputStream();
                BufferedReader bis = new BufferedReader(new InputStreamReader(is));
                String msg;
                if ((msg = bis.readLine()) != null ){
                    System.out.println("服务器接收到：" + msg);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }


}
